<%-- 
    Document   : nuevo
    Created on : 29/10/2009, 04:34:37 PM
    Author     : FreddyHIQ
--%>

<%@page contentType="text/html" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<link href="/general/css/admin_1.css" rel="stylesheet" type="text/css"/>
<script language="JavaScript" type="text/javascript" src="/tramite/javaScript/scripts.js"></script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<f:view>    
    <t:div>
        <h:form id="frmDocumentos" styleClass="fondoFormulariosyPanel" enctype="multipart/form-data">
            <h:panelGrid columns="1" styleClass="rayaForms" width="100%">
                <h:outputLabel  value="Envio de Documentos" />
            </h:panelGrid>
            <a4j:outputPanel ajaxRendered="true">
                <h:messages id="lblMessages" styleClass="messages" infoClass="infoClass" errorClass="errorClass"
                            warnClass="warnClass" fatalClass="fatalClass" showDetail="true" errorStyle="color:red;"
                            warnStyle="color:green;" infoStyle="color:black;" fatalStyle="color:black"/>
            </a4j:outputPanel>
            <h:inputHidden value="#{documentosController.inicializar}"/>
            <br/>
            <h:panelGrid columns="2">
                <h:outputLabel style="float:right" value="De:"/>
                <h:panelGrid id="panelArea" columns="3">
                    <h:outputLabel  value="#{documentosController.empleado.personaNatural.nombreCompleto}" />
                    <h:selectOneMenu value="#{documentosController.areaSeleccionada}" rendered="#{documentosController.estadoComboArea}">
                        <f:selectItem itemLabel="Seleccione Area" itemValue="" />
                        <f:selectItems value="#{documentosController.areaItems}" />
                        <a4j:support ajaxSingle="true" event="onchange" reRender="panelArea" />
                    </h:selectOneMenu>
                    <h:outputLabel value=" - #{documentosController.areaSeleccionada.areNombre}" rendered="#{!documentosController.estadoComboArea}"/>
                    <h:selectOneMenu value="#{documentosController.cargoSeleccionado}" rendered="#{documentosController.estadoComboCargo}">
                        <f:selectItem itemLabel="Seleccione Cargo" itemValue="" />
                        <f:selectItems value="#{documentosController.cargoItems}" />
                        <a4j:support ajaxSingle="true" event="onchange" reRender="panelArea" />
                    </h:selectOneMenu>
                    <h:outputLabel value=" - #{documentosController.cargoSeleccionado.carDescripcion}" rendered="#{!documentosController.estadoComboCargo}"/>
                </h:panelGrid>
                <h:outputLabel style="float:right" value="Para:"/>
                <h:panelGrid columns="2">
                    <h:panelGroup>
                        <div class="cajaTextoDiv" onclick="moverCursortxt();">
                            <a4j:outputPanel id="panelS" ajaxRendered="true">
                                <t:dataList value="#{documentosController.destinatarios}" var="dest">
                                    <div id="lblBoton" class="labelBoton" onmouseover="sobreLabel();">
                                        <h:outputLabel value=" #{dest.nombre} "/>
                                        <a4j:commandButton title="eliminar" image="/img/eliminar.png" action="#{documentosController.eliminarDest}">
                                            <f:setPropertyActionListener target="#{documentosController.empleadoAdap}" value="#{dest}" />
                                        </a4j:commandButton>
                                    </div>
                                </t:dataList>
                            </a4j:outputPanel>                                                             
                            <h:inputText id="txtDestinatario" value="#{documentosController.nombre}" rendered="#{!documentosController.respuesta}" maxlength="180" styleClass="cajaSinBorde"/>
                            <rich:suggestionbox width="600" height="100" for="txtDestinatario" fetchValue=""
                                                suggestionAction="#{documentosController.autocompletarDestinatarios}"
                                                var="item" minChars="1" nothingLabel="No existe Destinatarios">
                                <h:column>
                                    <h:outputText value="#{item.nombre}" />
                                </h:column>
                                <a4j:support ajaxSingle="true" reRender="panelS" event="onselect" action="#{documentosController.agregarDestin}">
                                    <f:setPropertyActionListener value="#{item}" target="#{documentosController.empleadoAdap}" />
                                </a4j:support>
                            </rich:suggestionbox>
                        </div>
                    </h:panelGroup>                    
                    <a4j:outputPanel id="btn">
                        <a4j:commandButton action="#{documentosController.verCC}" value="CC" ajaxSingle="true" reRender="panCC, panCC1, panelM, btn" rendered="#{!documentosController.estadoCC}"/>
                    </a4j:outputPanel>
                </h:panelGrid>
                <a4j:outputPanel id="panCC1" ajaxRendered="#{!documentosController.estadoCC}">
                    <h:panelGrid style="float:right" columns="1" rendered="#{documentosController.estadoCC}">
                        <h:outputLabel style="float:right" value="CC:" />
                    </h:panelGrid>
                </a4j:outputPanel>
                <a4j:outputPanel id="panCC" ajaxRendered="#{!documentosController.estadoCC}">
                    <h:panelGrid columns="1" rendered="#{documentosController.estadoCC}">
                        <h:panelGroup>
                            <div class="cajaTextoDiv" onclick="moverCursorCC();">
                                <a4j:outputPanel id="panelCC" ajaxRendered="true">
                                    <t:dataList value="#{documentosController.cc}" var="dest">
                                        <div class="labelBoton" onmouseover="sobreLabel();">
                                            <h:outputLabel value=" #{dest.nombre} "/>
                                            <a4j:commandButton title="eliminar" image="/img/eliminar.png" action="#{documentosController.eliminarCC}">
                                                <f:setPropertyActionListener target="#{documentosController.empleadoAdap}" value="#{dest}" />
                                            </a4j:commandButton>
                                        </div>
                                    </t:dataList>
                                </a4j:outputPanel>
                                <h:inputText id="txtCC" value="#{documentosController.nombre}" maxlength="180" styleClass="cajaSinBorde"/>
                                <rich:suggestionbox width="600" height="100" for="txtCC" fetchValue=""
                                                    suggestionAction="#{documentosController.autocompletarDestinatarios}"
                                                    var="item" minChars="1" nothingLabel="No existe Destinatarios">
                                    <h:column>
                                        <h:outputText value="#{item.nombre}" />
                                    </h:column>
                                    <a4j:support ajaxSingle="true" reRender="panelCC" event="onselect" action="#{documentosController.agregarCC}">
                                        <f:setPropertyActionListener value="#{item}" target="#{documentosController.empleadoAdap}" />
                                    </a4j:support>
                                </rich:suggestionbox>
                            </div>
                        </h:panelGroup>
                    </h:panelGrid>
                </a4j:outputPanel>
                <h:outputLabel style="float:right" value="Asunto:" />
                <h:inputText value="#{documentosController.asunto}" size="130" />
            </h:panelGrid>
            <%--<a4j:outputPanel id="panelD" ajaxRendered="true">--%>
            <a4j:outputPanel id="panelD" >
                <h:panelGrid columns="6">
                    <h:outputLabel  value="Tipo Documento:" />
                    <h:selectOneMenu value="#{documentosController.tipDocSeleccionado}">
                        <f:selectItem itemLabel="Seleccionar Documento" value=""/>
                        <f:selectItems value="#{tipoDocumentoController.tipoDocumentoCombo}" />
                        <a4j:support ajaxSingle="true" event="onchange" reRender="panelD" action="#{documentosController.cambioDoc}" />
                    </h:selectOneMenu>
                    <h:outputLabel  value="Plantillas Publicas" />
                    <h:selectBooleanCheckbox value="#{documentosController.publico}">
                        <a4j:support ajaxSingle="true" event="onchange" reRender="panelD" action="#{documentosController.cambioDoc}"/>
                    </h:selectBooleanCheckbox>
                    <h:outputLabel  value="Plantillas:" />
                    <h:selectOneMenu value="#{documentosController.plantillaSeleccionada}" >
                        <f:selectItem itemLabel="Seleccionar Plantilla" value=""/>                        
                        <f:selectItems value="#{documentosController.plantillaCombo}" />
                        <a4j:support ajaxSingle="true" event="onchange" reRender="panelD" action="#{documentosController.cambioPlantilla}" />
                    </h:selectOneMenu>
                </h:panelGrid>
                <h:panelGrid columns="6">
                    <h:commandButton action="#{documentosController.enviar}" value="Enviar" />
                    <h:commandButton action="#{documentosController.guardar}" value="Guardar como Plantilla" />
                </h:panelGrid>
                <rich:editor id="editor" width="800" height="400" value="#{documentosController.editor}"
                             theme="advanced">
                    <f:param name="theme_advanced_toolbar_location" value="top"/>
                    <f:param name="theme_advanced_toolbar_align" value="left"/>
                </rich:editor>
                <rich:modalPanel height="150" width="350" id="Modal2" resizeable="false" moveable="false" showWhenRendered="true" rendered="#{documentosController.modalObserv}">
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="Plantilla" />
                        </h:panelGroup>
                    </f:facet>
                    <h:panelGroup>
                        <h:panelGrid columns="2">
                            <h:outputLabel value="Nombre:"/>
                            <h:inputText value="#{documentosController.plantilla.plaNombre}" />
                            <h:outputLabel  value="Publica" />
                            <h:selectBooleanCheckbox value="#{documentosController.plantilla.plaPublico}"/>
                            <h:commandButton id="btnAceptar" value="Aceptar" action="#{documentosController.aceptarPlantilla}"/>
                            <h:commandButton id="btnCancelar" value="Cancelar" action="#{documentosController.cancelarPlantilla}" />
                        </h:panelGrid>
                        <rich:componentControl for="Modal2" attachTo="btnAceptar, btnCancelar" operation="hide" event="onclick"/>
                    </h:panelGroup>
                </rich:modalPanel>
            </a4j:outputPanel>  
        </h:form>
    </t:div>
</f:view>